package com.econ.powercloud.ems.controller;

import com.econ.powercloud.common.base.facade.pojo.MsgResult;
import com.econ.powercloud.ems.aop.UserOperatePower;
import com.econ.powercloud.ems.pojo.YkYtIssueConfirmVO;
import com.econ.powercloud.ems.pojo.requestVO.*;
import com.econ.powercloud.ems.service.biz.EmsYkYtIssueService;
import com.econ.powercloud.ems.util.NetUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author : zjf
 * @Description : ems项目中遥控遥调下发controller
 * @Date : 2021/10/14 9:46
 * @Modified by : zjf
 */
@Api(tags = "遥控遥调下发管理")
@RestController
@RequestMapping(value = "/api/v2/remote/issue")
public class EmsYkYtIssueController extends ApiBaseController{

    @Autowired
    private EmsYkYtIssueService emsYkYtIssueService;

    @UserOperatePower
    @ApiOperation(value = "下发数据")
    @PutMapping(value = "modifyData")
    public MsgResult modifyData(@Validated @RequestBody EmsIssueRequestVO emsIssueRequestVO) {
        return emsYkYtIssueService.modifyYtData(emsIssueRequestVO);
    }

    @UserOperatePower
    @ApiOperation(value = "根据点号类型下发遥控遥调数据")
    @PutMapping(value = "modifyDataByDitType")
    public MsgResult modifyDataByDitType(@Validated @RequestBody YkYtIssueRequestVO requestVO){
        return emsYkYtIssueService.modifyDataByDitType(requestVO);
    }

    @UserOperatePower
    @ApiOperation("批量下发遥控遥调（群控群调）")
    @PostMapping("batchPush")
    public MsgResult<Boolean> batchPush(@Validated @RequestBody SingleListRequestVO<YkYtIssueRequestVO> requestVO) {
        return successHandler(emsYkYtIssueService.groupControl(requestVO.getList(),NetUtils.getClientIp()));
    }

    @ApiOperation("获取遥控遥调对应的反馈与实时点号数据")
    @PostMapping("getYkYtIssueConfirmData")
    public MsgResult<List<YkYtIssueConfirmVO>> getYkYtIssueConfirmData(@Validated @RequestBody SingleListRequestVO<YkYtIssueRequestVO> requestVO){
        return successHandler(emsYkYtIssueService.getYkYtIssueConfirmData(requestVO.getList()));
    }
}
